class Node:
    def __init__(self, initdate):
        self.date = initdate
        self.next = None

    def setDate(self, newdate):
        self.date = newdate

    def getDate(self):
        return self.date

    def setNext(self, newnext):
        self.next = newnext

    def getNext(self):
        return self.next


class UnorderedList:
    def __init__(self):
        self.head = None

    def add(self, item):
        temp = Node(item)
        temp.setNext(self.head)
        self.head = temp

    def length(self):
        current = self.head
        count = 0
        while current != None:
            current = current.getNext()
            count += 1
        return count

    def search(self, item):
        current = self.head
        found = False
        while not found:
            if current.getDate() == item:
                found = True
            else:
                current = current.getNext()
        return found

    def remove(self, item):
        current = self.head
        found = False
        previous = None
        while not found :
            if current.getDate() == item:
                found = True
            else:
                if current.getNext()==None:
                    break
                else:
                    previous = current
                    current = current.getNext()
        if previous == None:
            self.head = current.getNext()
        else:
            if found==False:
                print("该链表没有该数值")
            else:
                previous.setNext(current.getNext())

    def date(self):
        currrent = self.head
        lt = []
        while currrent != None:
            lt.append(currrent.getDate())
            currrent = currrent.getNext()
        return lt


lt = UnorderedList()
lt.add(54)
lt.add(26)
lt.add(93)
lt.add(17)
lt.add(77)
lt.add(31)
print(lt.length())
lt.remove(17)
print(lt.length())
print(lt.search(77))
lt2 = []
for i in lt.date():
    lt2.append(str(i))
print('->'.join(lt2))
lt.remove(60)
print()
